<template>
    <div class="mui-numbox" data-numbox-min='1' style="height: 25px">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <!--子组件中需要以某种方式例如点击事件的方法来触发一个自定义事件，然后在自定义事件中执行父组件传来的方法-->
        <input id="test" class="mui-input-numbox" type="number" :value="initcount" ref="numbox" @change="countChanged"
               readonly/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
  import mui from '../../lib/mui/js/mui.min.js'

  export default {
    mounted() {
      //初始化数字选择框
      mui('.mui-numbox').numbox()
    },
    methods: {
      countChanged() {
        //数量改变了
        // console.log(this.$refs.numbox.value)
        this.$store.commit("updateGoodsInfo", {id: parseInt(this.goodsid), count: this.$refs.numbox.value})
      }
    },
    props: ["initcount", "goodsid"]
  }
</script>

<style scoped>

</style>